Vue.prototype.getUrlKey = function (name) {
    return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ""])[1].replace(/\+/g, '%20')) || null
}

var app = new Vue({
    el: '#app',
    data: {
        form: {
            community_id: 0,
            current_page: 1,
            total: 0,
            page_size: 15
        },
        table: {
            list: []
        },
        pageInfo: {
            title: '楼盘列表'
        }
    },
    mounted:function(){
        this.form.community_id = this.getUrlKey('community_id');
        this.getBuildingList();
    },
    methods: {
        getBuildingList: function() {
            var _this = this;
            $.ajax({
                url: '/building/getList',
                type: 'get',
                data: _this.form,
                dataType: 'json',
                success: function(res) {
                    if (res.status === 0) {
                        _this.table.list = res.data.data;
                        _this.form.current_page = res.data.current_page;
                        _this.form.total = res.data.total;
                    } else {
                        _this.$message.error(res.message)
                    }
                }
            })
        },
        handleCurrentChange: function(val) {
            this.form.current_page = val;
            this.getBuildingList();
        },
    }
});
$(document).keyup(function(e){
    var key = e.which;
    if(key==13){
        app.getBuildingList();
        return false;
    }
});
